import java.util.Scanner;

public class Main {
    /**
     * JAVA21 补全构造方法
     * @param args
     */
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            int z = scanner.nextInt();
            Sub sub = new Sub(x, y, z);
            System.out.println(sub.calculate());
        }
    }

}

class Base {

    private int x;
    private int y;

    public Base(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

}

class Sub extends Base {

    private int z;

    public Sub(int x, int y, int z) {
        
        //write your code here
        super(x,y);
        this.z = z;

    }

    public int getZ() {
        return z;
    }

    public int calculate() {
        return super.getX() * super.getY() * this.getZ();
    }

    /**
     * JAVA23 定义打印方法
     * @param args
     * @throws Exception
     */

    public static void main2(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String className = scanner.next();
            // print就是需要你定义的方法
            print(Class.forName(className).newInstance());
        }
    }

    //write your code here......
    public static void print(Object o){
        System.out.print(o);
    }

}

class First {
    public String toString() {
        return "First";
    }
}

class Second {
    public String toString() {
        return "Second";
    }
}

class Third {
    public String toString() {
        return "Third";
    }


    /**
     * JAVA24 类型判断
     * @param args
     * @throws Exception
     */
    public static void main3(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String className = scanner.next();
            Base obj = (Base) Class.forName(className).newInstance();
            System.out.println(getClassName(obj));
        }
    }

    public static String getClassName(Base obj) {

        //write your code here......
       /*instanceof关键字的使用，它是多态性中父类引用向下转型的前置判断手段.
        有效控制了类的转换异常ClassCastException的出现*/
        if (obj instanceof Sub1){
            return "Sub1";
        }else if(obj instanceof Sub2){
            //return "Sub2";
            Sub1 sub1 = (Sub1) obj;
            sub1.getClass().getSimpleName();

        }else{
            return "Base";

        }

    }



class Base {

}

class Sub1 extends Base {

}

class Sub2 extends Base {

}

    /**
     * JAVA25 实现抽象方法
     * @param args
     */
    public static void main4(String[] args) {
        // Sub是需要你定义的子类
        Base base = new Sub();

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            base.setX(x);
            base.setY(y);
            System.out.println(base.calculate());
        }
    }



abstract class Base {

    private int x;
    private int y;

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int calculate() {
        if (avg() == 0) {
            return 0;
        } else {
            return sum() / avg();
        }
    }

    /**
     * 返回x和y的和
     */
    public abstract int sum();

    /**
     * 返回x和y的平均值
     */
    public abstract int avg();

}

class Sub extends Base {

    //write your code here......
    public int sum(){
        return getX()+getY();
    }
    public int avg(){
        return this.sum()/2;

    }


}

    /**
     * JAVA26 实现接口
     * @param args
     */
    public static void main5(String[] args) {
        Comparator comparator = new ComparatorImpl();

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            System.out.println(comparator.max(x, y));
        }
    }

}

interface Comparator {
    /**
     * 返回两个整数中的最大值
     */
    int max(int x, int y);
}

//write your code here......
class ComparatorImpl implements Comparator{
    public int max(int x,int y){
        return x > y ? x:y;
    }
}
}
